﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;


public partial class Trail : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack && AppUser.currUser() == 0)
        {
            Response.Redirect("../Login.aspx");
        }
        if (!Page.IsPostBack && Request["TrailID"] != null)
        {
            int ID = 0;
            int.TryParse(Request["TrailID"].ToString(), out ID);
            if (ID != 0)
            {
                GMap1.TrailID = ID;
                GMap1.LoadTrail();
            }
            if (GMap1.ViewMode)
            {
                btnSave.Text = "Back";
                btnSave.CssClass = "form_btn";

            }
        }
    }


    protected void btnSave_Click(object sender, EventArgs e)
    {
        HiddenField hf =  (HiddenField) GMap1.FindControl("hfTrailName");

        if (!GMap1.ViewMode)
        {
       
           GMap1.SaveTrail();
            Response.Redirect("AddTrail.aspx?TrailID=" + GMap1.TrailID.ToString() + "&trailname=" + hf.Value);
        }
        else
            Response.Redirect("trail-details.aspx?TrailID=" + GMap1.TrailID.ToString() + "&trailname=" + hf.Value);
    }
}
